/*
 *  CustomAssert.h
 *  Musix001
 *
 *  Created by jiji on 08/03/13.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include <assert.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>

using namespace std;

#define Assert( expression ) \
	if ( ! ( expression ) ) { \
		cout << "Assert fail, "<< __FILE__ << ":"<< __LINE__ << ":" << # expression \
			 << " but, " << ( expression ) << "\n"; \
	}

#define AssertTrue( expression ) \
	if ( ! ( expression ) ) { \
		cout << "AssertTrue fail, "<< __FILE__ << ":"<< __LINE__ << ":" << # expression \
			 << " but, " << ( expression ) << "\n"; \
	}

#define AssertFalse( expression ) \
	if ( ( expression ) ) { \
		cout << "AssertFalse fail, "<< __FILE__ << ":"<< __LINE__ << ":" << # expression \
			 << " but, " << ( expression ) << "\n"; \
	}

#define AssertEqual( expression, expression2 ) \
	if ( ( expression ) != ( expression2 ) ) { \
		cout << "AssertEqual fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << "==" << # expression2 \
			 << " but, " << ( expression ) << " == " << ( expression2 ) << "\n"; \
	}

#define AssertEqualWithMessage( expression, expression2, message ) \
	if ( ( expression ) != ( expression2 ) ) { \
		cout << "AssertEqual fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << "==" << # expression2 \
			 << " but, " << ( expression ) << " == " << ( expression2 ) << "\t" \
			 << message << "\n"; \
	}

#define AssertNotEqual( expression, expression2 ) \
	if ( ( expression ) == ( expression2 ) ) { \
		cout << "AssertEqual fail, "<< __FILE__ << ":"<< __LINE__ << ":" << # expression << "!=" << # expression2 \
			 << " but, " << ( expression ) << " == " << ( expression2 ) << "\n"; \
	}

#define AssertEqualWithError( expression, expression2, error ) \
	if ( std::abs( ( expression ) - ( expression2 ) ) > ( error ) ) { \
		cout << "AssertEqual fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << "==" << # expression2 \
			 << " but, " << ( expression ) << " == " << ( expression2 ) << "\n"; \
	}

#define AssertLess( expression, expression2 ) \
	if ( ! ( ( expression ) < ( expression2 ) ) ) { \
		cout << "AssertEqual fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << "<" << # expression2 \
			 << " but, " << ( expression ) << " < " << ( expression2 ) << "\n"; \
	}

#define AssertLessOrEqual( expression, expression2 ) \
	if ( ! ( ( expression ) <= ( expression2 ) ) ) { \
		cout << "AssertLessOrEqual fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << "<=" << # expression2 \
			 << " but, " << ( expression ) << " <= " << ( expression2 ) << "\n"; \
	}

#define AssertGreater( expression, expression2 ) \
	if ( ! ( ( expression ) > ( expression2 ) ) ) { \
		cout << "AssertGreater fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << ">" << # expression2 \
			 << " but, " << ( expression ) << " > " << ( expression2 ) << "\n"; \
	}

#define AssertGreaterOrEqual( expression, expression2 ) \
	if ( ! ( ( expression ) >= ( expression2 ) ) ) { \
		cout << "AssertGreaterOrEqual fail, " << __FILE__ << ":"<< __LINE__ << ":" << # expression << ">=" << # expression2 \
			 << " but, " << ( expression ) << " >= " << ( expression2 ) << "\n"; \
	}

#define AssertFail() \
	cout << "AssertFail, " << __FILE__ << ":"<< __LINE__ << "\n";
